import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
class Base():
    #初始化
    def __init__(self,dr):
        self.dr=dr
    #打开页面
    def get_url(self,url):
        self.dr.get(url)
    #显示等待
    def find_element(self,loc):
        try:
            WebDriverWait(self.dr,20,0.5).until(lambda dr:self.dr.find_element(*loc).is_displayed())
            return self.dr.find_element(*loc)
        except Exception as e:
            print(e)
    #强制等待
    def sleep(self,s):
        time.sleep(s)
    #隐式等待
    def xs(self,s):
        self.dr.implicitly_wait(s)
    #返回文本值
    def text(self,loc):
        return self.find_element(loc).text
    #输入操作
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    #点击操作
    def click(self,loc):
        self.find_element(loc).click()
    #键盘输入回车
    def huic(self,loc):
        self.find_element(loc).send_keys(Keys.ENTER)
    #进入框架
    def kj(self,loc):
        a=self.find_element(loc)
        self.dr.switch_to.frame(a)
    #最大化
    def zuida(self,loc):
        a=self.dr.maximize_window()